from tortoise.models import Model
from tortoise import fields
import datetime
from models.base import  *


class Enterprise(TimestampMixin, OtherMixin, TenantMixin, UidMixin, Model):
    name = fields.CharField(max_length=50, description="enterprise name")
    mobile = fields.CharField(max_length=50, description="enterprise mobile")
    state = fields.IntField(description="1 default", default=0)
    activate = fields.IntField(description="activate 1", default=0)

    class Meta:
        abstract = False
        table = 'a_enterprise'
        table_description = '企业信息表'

    async def list_to_dict(self):
        request_dict = {f: getattr(self, f) for f in self._meta.fields}
        request_dict['create_ts'] = datetime.datetime.strftime(request_dict['create_ts'], '%Y-%m-%d')
        request_dict['update_ts'] = datetime.datetime.strftime(request_dict['update_ts'], '%Y-%m-%d')
        return request_dict
